#include <bits/stdc++.h>
#define ALL(x) begin(x), end(x)
using namespace std;
void file() {
  freopen("kte.in", "r", stdin);
  freopen("kte.out", "w", stdout);
}
using ll = long long;

namespace QwQ {
  const int kN = 4e5 + 5, kS = 1.6e6 + 5;
  int q, n;
  array<ll, kN> a, b, tmp;
  array<bool, kN> vis;

  #define ls (o << 1)
  #define rs (o << 1 | 1)

  struct SGT {
    array<int, kS> siz;
    array<ll, kS> sum, ps, ss;

    void pu(int o) {
      siz[o] = siz[ls] + siz[rs];
      sum[o] = sum[ls] + sum[rs];
      ps[o] = ps[ls] + ps[rs] + sum[ls] * siz[rs];
      ss[o] = ss[rs] + ss[ls] + sum[rs] * siz[ls];
    }
    void update(int o, int l, int r, int x, int t) {
      if(l == r) {
        siz[o] += t;
        sum[o] += t * b[x];
        ps[o] += t * b[x], ss[o] += t * b[x];
        return ;
      }
      int mid = (l + r) >> 1;
      if(mid < x) {
        update(rs, mid + 1, r, x, t);
      }else {
        update(ls, l, mid, x, t);
      }
      pu(o);
    }
    ll qs(int o, int l, int r, int x, int y) {
      if((l > y) || (r < x)) return 0;
      if((l >= x) && (r <= y)) return sum[o];
      int mid = (l + r) >> 1;
      return qs(ls, l, mid, x, y) + qs(rs, mid + 1, r, x, y);
    }
    array<ll, 3> qps(int o, int l, int r, int k) {
      if(k == 0) return array<ll, 3> {0, 0, 0};
      if(l == r) return array<ll, 3> {ps[o], sum[o], siz[o]};
      int mid = (l + r) >> 1;
      array<ll, 3> left, right;
      if(siz[ls] >= k) return qps(ls, l, mid, k);
      left = array<ll, 3> {ps[ls], sum[ls], siz[ls]};
      right = qps(rs, mid + 1, r, k - siz[ls]);
      array<ll, 3> ans;
      ans[0] = left[0] + right[0] + left[1] * right[2];
      ans[1] = left[1] + right[1];
      ans[2] = left[2] + right[2];
      return ans;
    }
    array<ll, 3> qss(int o, int l, int r, int k) {
      if(k == 0) return array<ll, 3> {0, 0, 0};
      if(l == r) return array<ll, 3> {ss[o], sum[o], siz[o]};
      int mid = (l + r) >> 1;
      array<ll, 3> left, right;
      if(siz[rs] >= k) return qss(rs, mid + 1, r, k);
      left = qss(ls, l, mid, k - siz[rs]);
      right = array<ll, 3> {ss[rs], sum[rs], siz[rs]};
      array<ll, 3> ans;
      ans[0] = left[0] + right[0] + right[1] * left[2];
      ans[1] = left[1] + right[1];
      ans[2] = left[2] + right[2];
      return ans;
    }
    ll qr(int o, int l, int r, int k) {
      if(l == r) return l;
      int mid = (l + r) >> 1;
      if(siz[ls] >= k) {
        return qr(ls, l, mid, k);
      }else {
        return qr(rs, mid + 1, r, k - siz[ls]);
      }
    }
    ll qkmins(int o, int l, int r, int k) {
      if(k == 0) return 0;
      if(l == r) return b[l];
      int mid = (l + r) >> 1;
      if(siz[ls] >= k) {
        return qkmins(ls, l, mid, k);
      }else {
        return sum[ls] + qkmins(rs, mid + 1, r, k - siz[ls]);
      }
    }
    ll qkmaxs(int o, int l, int r, int k) {
      if(k == 0) return 0;
      if(l == r) return b[l];
      int mid = (l + r) >> 1;
      if(siz[rs] >= k) {
        return qkmaxs(rs, mid + 1, r, k);
      }else {
        return sum[rs] + qkmaxs(ls, l, mid, k - siz[rs]);
      }
    }
    ll presum(int l, int r) {
      return qps(1, 1, q, r)[0] - qps(1, 1, q, l - 1)[0];
    }
    ll sufsum(int l, int r) {
      return qss(1, 1, q, r)[0] - qss(1, 1, q, l - 1)[0];
    }
  }sgt;

  ll solve() {
    int lim = (n - 1) / 2;
    int L1, R1, L2, R2;
    L1 = 0, R1 = lim + 1;
    L2 = lim, R2 = n;
    while(L1 + 1 < R1) {
      int mid = (L1 + R1) / 2;
      if(sgt.qkmins(1, 1, q, mid + 1) <= sgt.qkmaxs(1, 1, q, mid)) {
        R1 = mid;
      }else {
        L1 = mid;
      }
    }
    while(L2 + 1 < R2) {
      int mid = (L2 + R2) / 2;
      if(sgt.qkmins(1, 1, q, mid + 1) <= sgt.qkmaxs(1, 1, q, mid)) {
        L2 = mid;
      }else {
        R2 = mid;
      }
    }
    ll ans = 0;
    int pl = sgt.qr(1, 1, q, R1);
    int pr = sgt.qr(1, 1, q, L2);
    ans += sgt.qkmins(1, 1, q, L2 + 1);
    ans -= sgt.qkmins(1, 1, q, R1);
    ans += sgt.sufsum(1, L1) - sgt.presum(1, L1);
    ans += sgt.sufsum(R2, q) - sgt.presum(R2, q);
    return ans;
  }

  int main() {
    file();
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> q;
    for(int i = 1; i <= q; i++) {
      cin >> a[i], b[i] = a[i];
    }
    sort(b.data() + 1, b.data() + q + 1);
    int o = unique(b.data() + 1, b.data() + q + 1) - b.data() - 1;
    for(int i = 1; i <= q; i++) {
      a[i] = lower_bound(b.data() + 1, b.data() + o + 1, a[i]) - b.data();
    }
    for(int i = 1; i <= q; i++) {
      if(vis[a[i]] == 1) {
        n--, sgt.update(1, 1, q, a[i], -1);
      }else {
        n++, sgt.update(1, 1, q, a[i], 1);
      }
      vis[a[i]] ^= 1;
      cout << solve() << "\n";
    }
    return 0;
  }
}
int main() {
  return QwQ::main();
}